$('#add').click(function () {
    window.location.href = `/Student/CreateOrUp`
});
$('#save').click(
    function () {
        let id = $('[name=id]').val();
        let name = $('[name=name]').val();
        let classname = $('[name=classname]').val();
        let age = $('[name=age]').val();
        let obj = {
            id,
            name,
            classname,
            age
        };
        console.log(obj);
        $.post('/Student/save', obj, function () {
            window.location.href = `/Student/index`
        })
    }
)
function btnEdit(id) {
    window.location.href=`/Student/CreateOrup/${id}`
}
function btnDel(id) {
    window,location.href=`/Student/Delect/${id}`
}
$('#Query').click(
    function(){
        let keywork = $('#keywork').val();
        let obj = {
            keywork
        };
        $.post('/Student/Query',obj,function(res){
            console.log(res);
            $('.tab').html('')
            res.forEach(item=>{
                let html=`
                <tr class="tab">
                    <th>${item.id}</th>
                    <th>${item.name}</th>
                    <th>${item.classname}</th>
                    <th>${item.age}</th>
                    <th><input class="btnEdit" type="button" value="编辑" onclick="btnEdit(${item.id})">
                    <input class="btnDel" type="button" value="删除" onclick="btnDel(${item.id})"></th>
                </tr>`
                $('#bigdiv').append(html);
            })
        })
    }
)
$('#quxiao').click(function(){
    window.location.href=`/Student/index`
})